package com.mobile.mo.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @program: LazyHabit
 * @description: Api接口返回的统一结果类型
 * @author: Feri
 * @create: 2024-11-18 14:14:01
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {
    private int code;
    private String msg;
    private T data;

    /**
    * 成功*/
    public static R<String> ok(){
        return ok(null);
    }
    /**
    * 成功 返回数据*/
    public static <T> R<T> ok(T obj){
        return new R(0,"操作成功",obj);
    }
    /**
    * 失败*/
    public static R fail(){
        return fail("本次请求操作失败！");
    }
    /**
    * 失败 返回内容*/
    public static R fail(String m){
        return new R(1,"操作失败",m);
    }
}
